package com.baidu.io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FileUtil {
    public static List<String[]> ReadFileLine(String path, String separate) throws Exception {
        // 1.创建缓冲流读取文件
        FileReader fileReader = new FileReader(path);
        BufferedReader bufferedReader = new BufferedReader(fileReader);

        // 2.逐行读取 并按照指定分隔符分割
        String line = null;
        ArrayList<String[]> resultList = new ArrayList<>();
        while (null != (line = bufferedReader.readLine())){
            String[] split = line.split(separate);
            resultList.add(split);
        }

        // 3.关闭资源
        bufferedReader.close();
        fileReader.close();

        return resultList;
    }
}
